package com.atguigu.yygh.msm.listener;

import com.atguigu.yygh.mq.pojo.MqConst;
import com.atguigu.yygh.msm.vo.MsmVo;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @description: rabbitmq消息监听器
 * @author: 化一帆
 * @date: 2022/12/9 18:06
 * @version: v1.0
 */
@Component
public class SmsReceiver {
    //消息消费者，监听第二个队列
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_MSM_ITEM, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_MSM),
            key = {MqConst.ROUTING_MSM_ITEM}
    ))
    //得到rabbitmq中的消息，进行控制台的输出
    public void send(MsmVo msmVo) {
        //模拟向指定手机号发送短信通知
        System.out.println(msmVo.getPhone() + msmVo.getParam().get("message"));
    }
}
